package com.xuecheng.content.controller.api;

import com.xuecheng.base.model.RestResponse;
import com.xuecheng.content.model.dto.AddCourseTeacherDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程-教师关系表 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
@RequestMapping("courseTeacher")
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService  courseTeacherService;

    @GetMapping("list/{courseId}")
    @ApiOperation("查询负责该课程的老师信息")
    public List<CourseTeacher> getTeacherInfo(@PathVariable Long courseId){
        return courseTeacherService.getTeacherInfo(courseId);
    }

    @PostMapping
    @ApiOperation("保存/修改教师信息")
    public RestResponse save(@RequestBody CourseTeacher courseTeacher ){
        courseTeacherService.saveOrUpdateTeacher(courseTeacher);
        return RestResponse.success("添加成功");
    }

    @DeleteMapping("/course/{courseId}/{id}")
    @ApiOperation("删除教师信息")
    public RestResponse deleteTeacher(@PathVariable Long id,@PathVariable Long courseId){
        courseTeacherService.removeById(id);
        return RestResponse.success("删除成功");
    }



}
